﻿@model IEnumerable<AmazeUI.bll.GetModel.PayOrder2>

@{
    ViewBag.Title = "系统订单页";
   
}
 
<div class="am-g"> 
    <div class="am-u-sm-12 am-u-md-3">
        <div class="am-form-group">
            <select data-am-selected="{btnSize: 'sm'}">
                <option value="option1">所有类别</option>
                 
            </select>
        </div>
    </div>
    <div class="am-u-sm-12 am-u-md-3">
        <div class="am-input-group am-input-group-sm">
            <input type="text" class="am-form-field" data-bind="value:wd">
            <span class="am-input-group-btn">
                <button class="am-btn am-btn-default" onclick="fy(1)" type="button">搜索</button>
            </span>
        </div>
    </div>
</div>
<div class="am-g">
    <div class="am-u-sm-12">
        <table class="am-table am-table-striped am-table-hover table-main">
            <thead>
                <tr>
                    <th>@Html.DisplayNameFor(a => a.OrderNo)</th>
                    <th>@Html.DisplayNameFor(a => a.Name)</th> 
                    <th>@Html.DisplayNameFor(a => a.Goods.BodyContent)</th> 
                    <th>@Html.DisplayNameFor(a => a.IsPay)</th> 
                    <th>@Html.DisplayNameFor(a => a.PartyOrderNo)</th> 
                    <th>@Html.DisplayNameFor(a => a.Phone)</th> 
                    <th>@Html.DisplayNameFor(a => a.AddTime)</th>
                    <th>操作</th>
                </tr>
            </thead>

            <tbody data-bind="foreach:$root.datalist">
                <tr>

                    <td data-bind="text:OrderNo"></td>
                    <td data-bind="text:Name"></td>
                    <td >
                        <a href="javascript:void(0)" class="am-btn-link" data-bind="click:function(){$root.showgoods(Goods2)}">点击查看</a>
                    </td>
                    <td data-bind="text:IsPay?'已付':'未支付'"></td>
                    <td data-bind="text:PartyOrderNo"></td>
                    <td data-bind="text:Phone"></td>
                    <td data-bind="text:AddTime"></td>
                    <td>
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs"> 
                                <button class="am-btn am-btn-default am-text-danger am-btn-xs am-hide-sm-only" data-bind="click:$root.pay,disable:IsPay"><span class="am-icon-copy">后台付款</span> </button> 
                            </div>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>

        <!-- /用户列表 -->
        <!--分页-->
        <div data-bind="with:page">
            <a class="am-badge  am-radius  am-text-sm am-badge-secondary" data-bind="click:function(){$root.gopage(1)}">第一页</a>
            <a class="am-badge  am-radius  am-text-sm am-badge-secondary" data-bind="click:function(){$root.gopage(up)}">上一页</a>
            <!--ko foreach: vp-->
            <a class="am-badge  am-radius  am-text-sm" data-bind="css:{'am-badge-secondary ':$data!=$parent.page,'disabled':$data==$parent.page},text:$data,click:function(){$root.gopage($data)}">2</a>
            <!--/ko -->

            <a class="am-badge  am-radius  am-text-sm am-badge-secondary" data-bind="click:function(){$root.gopage(next)}">下一页</a>
            <a class="am-badge  am-radius  am-text-sm am-badge-secondary" data-bind="click:function(){$root.gopage(total)}">最后一页</a>
        </div>
        <!--分页-->
    </div>
</div>

@Html.Partial("alert")

@section scripts{
    <script type="text/javascript" src="/Resource/knockout-3.3.0.js"> </script>
    <script type="text/javascript">
        function Kvm() {
            var k = this;
            //数据集
            k.page = ko.observable();
            k.datalist = ko.observableArray([]);

            k.wd = ko.observable('');
            k.showgoods = function ($model) {
                $alert2(JSON.stringify($model));
            }
            k.gopage = function(page) {
                fy(page);
            }
       
            k.pay = function ($model) {
                var ok = prompt("请输入ok");
                if (ok == "ok") {
                    alert("ok");
                    $.doPost('@Url.Action("GoPay", "Admin")', { id: $model.Id }, function (d) {

                        fy(kvm.page().page);
                    });
                }
                
            } 
    }

        var kvm = new Kvm();
        ko.applyBindings(kvm);

        //获取数据
        function fy(page, rows) {
            //行数
            rows = rows || 10;
            $.doPost('@Url.Action("dataPayOrderlist", "Admin")', { page: page, rows: rows, wd: kvm.wd() }, function (d) {
                var opage = $page(page, rows, d.data.count); //绑定
                kvm.page(opage);
                kvm.datalist(d.data.datalist);

            });
        }

        $(function () {
            fy(1);
        });


    </script>
}
